<script>
import LendMoneyDetailList from '../../components/lendMoneyDetailList'
export default {
  components: {LendMoneyDetailList}
}
</script>

<template>
    <div class="page_recommendPersons">
        <van-nav-bar title="申请借支详情" left-arrow @click-left="$router.back()">
        </van-nav-bar>

        <div style="margin-top: 10px; box-sizing: border-box; text-align: center; background-color: #ffffff">
            <!-- 推荐人员列表， 封装组件   -->
            <div class="recommend_list">
                <!-- 将这某一项分封装为一个组件   -->
                <lend-money-detail-list v-for="(item, index) in advanceList" :item="item" :key="index">
                </lend-money-detail-list>
            </div>

            <van-divider style="margin-top: 80px" v-if="!advanceList || !advanceList.length">暂无数据</van-divider>

            <!-- 分页  -->
            <div class="bottomPage" style>
                <van-pagination v-model="params.pageIndex" :total-items="total" :items-per-page="params.pageSize"
                    force-ellipses @change="handleChange" />
            </div>
        </div>
    </div>
</template>

<script>
import lendMoneyDetailList from '../../components/lendMoneyDetailList'
import comAdvanceList from '../../components/comAdvanceList'
import comHeader from '../../components/comHeader'
import comFilterMenu from '../../components/comFilterMenu'

const rightOptionObj = {
  all: '全部用户',
  personal_user: '个人用户',
  enterprise_user: '企业用户'
}
const rightOption = [
  {text: '全部用户', value: 'all'},
  {text: '个人用户', value: 'personal_user'},
  {text: '企业用户', value: 'enterprise_user'}
]

export default {
  name: 'lendMoneyDetail', //recommendPersons
  components: {
    lendMoneyDetailList,
    comAdvanceList,
    comHeader,
    comFilterMenu
  },
  data() {
    return {
      showOverlay: false,
      keyWord: 'lendMoneyDetail', //recommendPersons
      rightValue: 'all',
      rightOption,
      rightOptionObj,

      advanceList: [],
      params: {
        UserId: this.$route.query.user_id,
        PositionId: this.$route.params.id,
        pageIndex: 1,
        pageSize: 10
      },
      total: 0
    }
  },

  mounted() {
    this._initPage(this.params)
  },

  methods: {
    goNeedPage(val) {
      const keyWord = this.keyWord
      if (val === 'search') {
        this.$router.push({
          path: `/searchRecords/${keyWord}`
        })
      }
    },
    _initPage(params) {
      console.log('params', params)
      this.$api.myCompany.getAdvanceBillAll(params).then(res => {
        if (res.code === 200) {
          this.advanceList = res.data.aplist
          this.total = res.data.count
        }
      })
    },
    toGetFilterMenuValue(val) {
      //过滤后返回第一页
      this.params.pageIndex = 1
      this.params.state = ''
      if (val == 'personal_user') {
        this.params.state = 1
        //个人用户
      } else if (val == 'enterprise_user') {
        //企业用户
        this.params.state = 2
      }
      this._initPage(this.params)
    },
    // 点击分页
    handleChange(value) {
      this.params.pageIndex = value
      this._initPage(this.params)
    }
  }
}
</script>

<style lang="scss" scoped>
.page_recommendPersons {
  width: 100%;
  .over_layer {
    margin-top: 46px;
    height: 100%;
    .layer {
      width: 36%;
      font-size: 14px;
      position: absolute;
      right: 0;
      z-index: 2;
    }
  }
  .head_title {
    height: 100px;
    width: 150px;
    border-radius: 50%;
    color: #fff;
    background-color: #0099ff;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
  }
  .recommend_list {
    padding-bottom: 50px;
    box-sizing: border-box;
    background-color: #ffffff;
    font-size: 12px;
  }

  .bottomPage {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: #fff;
  }
}
</style>
